<template>
  <a-form-item :name="formNamePath" :label="formItem.label" :rules="[formItem.rule]" :extra="formItem.extra"
    :style="{ marginLeft: formItem.marginLeft + 'px' }" class="form-a-radio-group">
    <a-select allowClear v-model:value="formItem.value" :disabled="formItem.disabled" @change="changeSelect" :mode="formItem.mode" :showSearch="formItem.showSearch"
      :style="{ width: '' + 'px' }" :placeholder="formItem.placeholder" :maxTagCount="formItem.maxTagCount"
      :options="formItem.options.map((item: any, index: number) => ({ value: item.value !== '' ? item.value : index + 1 + '', label: item.label ? item.label : item }))"></a-select>
    <div class="help-msg" v-if="formItem.helpMsg">
      {{ formItem.helpMsg }}
    </div>
  </a-form-item>
</template>

<script lang="ts" setup>
import { ref, reactive, watch, computed } from "vue";
import { dataSourceType } from "@/type.d";
import { useColumnItem } from "@/components/draggable/hooks/useColumnModel";
const emit = defineEmits(["changeSelect"]);
//props
const props = defineProps({
  formItem: {
    type: Object,
    default: {} as dataSourceType,
  },
  formNamePath: [],
});
const formItem: any = ref(props.formItem as any);
useColumnItem(
  computed(() => props.formItem),
  formItem
);

const changeSelect = (e: any) => {
  emit("changeSelect", formItem.value);
};
</script>

<style lang="less" scoped>
// ::v-deep(.ant-select-single:not(.ant-select-customize-input) .ant-select-selector) {
//   width: 100%;
// }

// ::v-deep(.ant-form-item-control-input) {
//   width: 100%;
// }

.help-msg {
  margin-top: 8px;
  font-size: 12px;
  font-family: PingFang SC-Regular, PingFang SC;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.45);
  line-height: 20px;
}
</style>
